package com.example.math_exam;

import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

public class ShopAdapter extends BaseQuickAdapter<ShopEntitiy, BaseViewHolder> {

    public ShopAdapter(int layoutResId) {
        super(layoutResId);
    }

    @Override
    protected void convert(BaseViewHolder helper, ShopEntitiy item) {

        /**
         * private ImageView mItemShopIcon;
         * private TextView mItemShopName;
         * private TextView mItemShopJian;
         * private TextView mItemShopNum;
         * private TextView mItemShopJia;
         */

        helper.setImageResource( R.id.item_shop_icon, item.getIcon());
        helper.setText(R.id.item_shop_name, item.getName());
        helper.setText(R.id.item_shop_price, "￥" + (item.getPrice() * item.getNum()) );
        helper.setText(R.id.item_shop_num, "" + item.getNum());

        if( item.isDelete()) helper.getView(R.id.item_shop_delete).setVisibility(View.VISIBLE);
        else helper.getView(R.id.item_shop_delete).setVisibility(View.GONE);

        helper.addOnClickListener( R.id.item_shop_delete, R.id.item_shop_jia, R.id.item_shop_jian);
    }
}
